<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>申请商家</title>
    <link rel="stylesheet" href="assets/css/amazeui.min.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="stylesheet" href="css/index/index.css">
</head>

<body>
    <header class="h45">
        <ul>
            <li class="header_left">
                <img src="img/left.png" width="10" height="16">
            </li>
            <li class="header_center">申请商家</li>
            <li class="header_right">
            </li>
        </ul>
    </header>

    <div class="applyForBusiness">
        <p class="h45 color_gray">
            按要求上传图片
        </p>
        <ul class="business_file_img">
            <li>
                <div class="fileInput_wrap">
                    <div>
                        <img class="imageFileInput1" src="img/license_img.png" alt="营业执照">
                        <input type="file" class="fileInput1">
                    </div>
                    <p>营业执照</p>
                </div>
            </li>
            <li>
                <div class="fileInput_wrap">
                    <div>
                        <img class="imageFileInput2" src="img/portals_img.png" alt="门头照片">
                        <input type="file" class="fileInput2">
                    </div>
                    <p>门头照片</p>
                </div>
            </li>
        </ul>
    </div>
    <div class="bottom_btn">
        <button class="h45" type="button">确定</button>
    </div>

    <script src="js/jquery-1.11.3.js"></script>
    <script>
        $(".fileInput1").change(function () {
            var objUrl = getObjectURL(this.files[0]);
            // console.log("objUrl = " + objUrl);
            if (objUrl) {
                $(".imageFileInput1").attr("src", objUrl);
            }
        });
        $(".fileInput2").change(function () {
            var objUrl = getObjectURL(this.files[0]);
            // console.log("objUrl = " + objUrl);
            if (objUrl) {
                $(".imageFileInput2").attr("src", objUrl);
            }
        });
        //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null;
            if (window.createObjectURL != undefined) { // basic
                url = window.createObjectURL(file);
            } else if (window.URL != undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file);
            } else if (window.webkitURL != undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file);
            }
            return url;
        }
    </script>

</body>

</html>